home *** CD-ROM | disk | FTP | other *** search
/ Java Developer's Companion / Java Developer's Companion.iso / Javacup / ED8N1T2I.ZIP / ED8N1T2I / education / ED8N1T2I / GND.java < prev    next >
Encoding:
Java Source  |  1996-05-21  |  3.4 KB  |  92 lines

  1. //****************************************************************************
  2. // ---- version information ----
  3. //
  4. // GND.java              v 1.00 b1
  5. // Written by:           I. van Rienen / E-mail ivr@bart.nl
  6. // URL:                  http://www/bart.nl/~ivr
  7. // Initial release:
  8. // Released in public domain:
  9. //
  10. // ---- Description ----
  11. // Java class containing methods for a logic GND
  12. //
  13. // This program and the Java source is in the public domain.
  14. // Permission to use, copy, modify, and distribute this software
  15. // and its documentation for NON-COMMERCIAL purposes and
  16. // without fee is hereby granted.
  17. //
  18. //    Copyright 1996
  19. //
  20. //    Iwan van Rienen
  21. //    Joan Maetsuyckerstr. 145
  22. //    2593 ZG  The Hague
  23. //    The Netherlands
  24. //
  25. // I am not responsible for any bugs in this program and
  26. // possible damage to hard- or software when using this program.
  27. //****************************************************************************
  28. import java.applet.Applet;
  29. import java.awt.*;
  30. import java.util.Vector;
  31.  
  32. class GND extends ElectronicComponent {
  33.  
  34. //----------------------------------------------------------------------------
  35. // The constructor of a GND pin
  36. //----------------------------------------------------------------------------
  37.     public GND(Pin PinGrid[][], int x, int y) {
  38.         super (x, y, 4, 4, 1, 1, 2, 3, 0, 1);      // x,y,w,h HitBox x,y,w,h, I,O
  39.         OPin[0] = new OutputPin("GND", 2, 1, 0, 2, 0, 0, ComponentPin.PIN_TEXT_INVISIBLE); // name, x, y, w, h, Flags
  40.         OPin[0].Level = 0;
  41.         ComponentName = "GND";
  42.         ClassName = "GND";
  43.         RegisterPins (PinGrid, x, y);
  44.     }
  45.  
  46. //----------------------------------------------------------------------------
  47. // The constructor of a new GND pin, which is a copy of CompToCopy
  48. //----------------------------------------------------------------------------
  49.     public GND (ElectronicComponent CompToCopy, int xo, int yo) {
  50.         super (CompToCopy, xo, yo);
  51.     }
  52.  
  53. //----------------------------------------------------------------------------
  54. // Method for copying this component.
  55. //----------------------------------------------------------------------------
  56.     public ElectronicComponent Copy(int xo, int yo) {
  57.         GND NewComponent = new GND(this, xo, yo);
  58.         NewComponent.OPin[0].Level = 0;
  59.  
  60.         return NewComponent;
  61.     }
  62.  
  63. //----------------------------------------------------------------------------
  64. // Method for drawing this GND pin
  65. //----------------------------------------------------------------------------
  66.     public void draw(Graphics g, int xp, int yp, int gs) {
  67.         super.draw (g, xp, yp, gs);
  68.         int x = Pos.x - xp;
  69.         int y = Pos.y - yp;
  70.  
  71.         // Draw HitBox and Dimension
  72.         // DrawHitBox(g, x, y, gs);
  73.  
  74.         // Draw The OutputPin
  75.         DrawOutputPins(g, x, y, gs);
  76.  
  77.         // Draw the body
  78.         g.setColor (Color.gray);
  79.         g.fillRect ((x + 1) * gs, (y + 3) * gs, gs * 2 + 1, gs / 2 - 1);
  80.     }
  81.  
  82. //----------------------------------------------------------------------------
  83. // Method for Simulating this component. All components connected to this
  84. // GND pin will be informed.
  85. //----------------------------------------------------------------------------
  86.     public void Simulate(int id) {
  87. //      System.out.println ("GND simulate()");
  88. //      System.out.println ("GND Simulate() ID= " + id);
  89.         InformConnectedComponents(id);
  90.     }
  91.  
  92. }